package com.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryDao extends BaseMapper<Category> {
    @Select("select * from category order by sort limit #{pagecount},#{pagesize}")
    public List<Category> getCategorylists(int pagecount,int pagesize);

    @Select("select count(*) from category")
    public Long selectcount();

    @Select("select * from category where name=#{name}")
    public Category selectcategorybyname(Category category);

    @Insert("insert into category (id,type,name,sort,create_time,update_time,create_user,update_user) values (#{id},#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    public void addCategory(Category category);

    @Delete("delete from category where id=#{ids}")
    public void deleteCategory(Long ids);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    public void updatebyid(Category category);

    @Select("select * from category where type=#{type}")
    public List<Category> getCategoryList(int type);

    @Select("select * from category where id=#{categoryId}")
    public Category selectbycategoryId(Long categoryId);

    @Select("select * from category")
    public List<Category> selectall();
}
